#include <iostream>
#include <boost/shared_ptr.hpp>

using namespace std;
using namespace boost;

void f()
{
    shared_ptr<int> a(new int (42));
    cout << a.use_count() << endl;

    shared_ptr<int> b = a;
    cout << a.use_count() << endl;
    {
        shared_ptr<int> c;
        shared_ptr<int> d (new int (314));

        cout << a.use_count() << endl;

        c = a;

        cout << a.use_count() << endl;

        d = c;

        cout << a.use_count() << endl;
    }

    cout << a.use_count() << endl;

    b.reset();

    cout << a.use_count() << endl;
}

int main()
{  
  f();
  return 0;
}


